<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%-- 
    Document   : search
    Created on : 05.06.2010, 2:29:55
    Author     : Cyclone
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<body>

    <%--<script src="js/courses.js" type="text/javascript"></script>--%>

    <%@include file="systemMessage.jsp" %>

    <!-- <div id="box"> -->
    <div id="box" style="overflow: auto;" class="rounded">
        <div id="rightnow" style="border: none;" class="rounded-top">
            <h3 class="reallynow rounded-top">
                Поиск
                <%--<c:if test="${sessionScope.roles.admin || sessionScope.role.tutor}">--%>
                <%--<c:if test='<%= request.isUserInRole("admin") || request.isUserInRole("tutor")%>'>--%>
                <%--<a class="add_page" onclick="$('div#newFormDiv').show('slow', function(){window.location = '#addCourse'});">Добавить курс</a>--%>
                <%--</c:if>--%>
                <br/>
            </h3>
        </div>
        <form id="form" action="Search" class="rounded-formcascade">
            <fieldset>
                <legend>Запрос</legend>
                <input type="text" name="q" style="width: 80%; float: left;" value="${param.q}"/>
                <input type="submit" style="width: 15%; float: right;" value="Поиск"/>
            </fieldset>

            <c:if test="${!empty resultList || !empty param.q}">
                <c:choose>
                    <c:when test="${!empty resultList}">
                        <br/>
                        <fieldset>
                            <legend>
                                Результат
                            </legend>
                            <table id="resultTable" class="datatable" align="left">
                                <thead>
                                    <tr>
                                        <th>Наименование</th>
                                        <th>Тип объекта</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <c:forEach var="result" items="${resultList}">
                                        <tr>
                                            <td>
                                                <a class="link" href="${result.link}">${result.name}</a>
                                            </td>
                                            <td>
                                                ${result.type}
                                            </td>
                                        </tr>
                                    </c:forEach>
                                </tbody>
                            </table>
                        </fieldset>
                    </c:when><c:otherwise>
                        <p>Поиск не дал результатов</p>
                    </c:otherwise>
                </c:choose>
            </c:if>
        </form>

    </div>
    <%--<br/>--%>


    <script type="text/javascript">
        $(document).ready(function(){
        <%--$("#liCourses").addClass("current");--%>
                $('div#top-panel p').text('Поиск объектов в системе');

                try { //  datatable
                    doDatatable('resultTable')
                } catch (e) {}
                // / datatable
            });
    </script>
</body>
